package com.speed_run.controller;

import com.speed_run.dto.CommentVo;
import com.speed_run.global.UserSession;
import com.speed_run.service.ICircleService;
import com.speed_run.utils.ResponseEntity;
import com.speed_run.vo.moment.MomentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RequestMapping("/v1/api/")
@RestController
public class CircleController {

    @Autowired
    private ICircleService circleService;
    /**
     * 获取圈子详情
     * @return
     */
    @GetMapping("/circle")
    public ResponseEntity CircleDetail(Integer circleId,Double lat, Double lng){
        return  circleService.circleDetail(circleId,lat,lng);
    }

    /**
     * 获取热门圈子
     * @return
     */
    @GetMapping("/circle/hot")
    public ResponseEntity  hotCircle(){
        return  circleService.hostCircle();
    }

    /**
     * 关注圈子
     * @return
     */
    @PostMapping("/circle/follow")
    public ResponseEntity followCircle(Integer id){
        return  circleService.followCircle(id);
    }

    /**
     * 取消关注圈子
     *
     * @return
     */
    @DeleteMapping("/circle/follow")
    public ResponseEntity unFollowCircle(Integer id){
        return  circleService.unFollowCircle(id);
    }


    /**
     * 获取个人关注圈子
     * @param
     * @return
     */
    @GetMapping("/circle/follow")
    public ResponseEntity getUserCircle(){
        return  circleService.getUserCircle(UserSession.get().getUserId());
    }

    /**
     * 圈子发布内容
     * @param
     * @return
     */
    @PostMapping("/circle/moment")
    public ResponseEntity Circle(@RequestParam(value = "framePic",required = false) MultipartFile framePic,
                @RequestParam(value = "video",required = false) MultipartFile video ,
                    @RequestParam(value = "album",required = false) MultipartFile[] album, MomentVo vo){
        return  circleService.circle(framePic,video,album,vo);
    }

    
    
    @GetMapping("/circle/index")
    public ResponseEntity indexCircle(Double lat, Double lng){
        return  circleService.indexCircle(lat,lng);
    }



    /**
     * 获取圈子列表内容
     * @param token
     * @return
     */
    @GetMapping("/circle/moment")
        public ResponseEntity getUserNewCircleContent(Integer type,String typeId, String userId,Integer page,Double lat, Double lng){
        return  circleService.momentByPage(type,typeId,userId,page,lat,lng);
    }




    /**
     * 删除圈子
     * @param data
     * @return
     */
    @PostMapping("/circle/moment/del")
    public ResponseEntity deleteCircle(Integer momentId){
        return  circleService.deleteCircle(momentId, UserSession.get().getUserId());
    }


    /**
     *
     * 圈子点赞
     *
     * @return
     */
    @PostMapping("/circle/moment/like")
    public ResponseEntity likeCirlce(Integer momentId){
        return circleService.likeCirlce(momentId);
    }

    /**
     * 创建评论
     * @param vo
     * @return
     */
    @PostMapping("/circle/moment/comment")
    public ResponseEntity commentAdd(@RequestBody CommentVo vo){
        return circleService.commentAdd(vo);
    }

    /**
     * 删除评论
     * @param commentId
     * @return
     */
    @PostMapping("/circle/moment/comment/del")
    public ResponseEntity commentAdd(Integer commentId){
        return circleService.delComment(commentId);
    }

    @GetMapping("/circle/moment/detail")
    public ResponseEntity getUserMomentDetail(Integer momentId,Double lng, Double lat) {
    	return circleService.getUserMomentDetail( momentId, lng,  lat);
    }
}
